package com.hf.lookatme;

import android.app.Activity;
import android.app.Application;

import com.baidu.location.LocationClient;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by JoeShiguang on 2015/5/15.
 */
public class Application_Mine extends Application {

  private RefWatcher refWatcher;

  public LocationClient locationClient;

  public List<Activity> list_allActivity;

  @Override
  public void onCreate() {
    super.onCreate();

    refWatcher = LeakCanary.install(this);
    locationClient = new LocationClient(this.getApplicationContext());
  }

  /**
   * 添加Activity
   * @param activity
   */
  public void addActivityToAllActivity(Activity activity){
    if(this.list_allActivity == null){
      this.list_allActivity = new ArrayList<Activity>();
    }
    list_allActivity.add(activity);
  }

  /**
   * finish掉所有已经存在的Activity
   */
  public void finishAllExistActivity(){
    if(list_allActivity == null){
      return;
    }
    if(list_allActivity.size() == 0){
      return;
    }
    for (int i=0; i<list_allActivity.size(); i++){
      list_allActivity.get(i).finish();
    }
  }
}
